﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using SubsidyApp.Models;

namespace SubsidyApp.Controllers
{
    public class SearchController : Controller
    {
        public class JsonContent
        {
            public int id;
            public int distrib_id;
            public string content_title;
            public string content_body;
        }

        public ActionResult Index(string text)
        {
            var site_query = from site_content in BasesDescription.db.site_contents
                             where site_content.content_body.Contains("text")
                             select site_content;

            var jsonQuery = from qElem in site_query
                            select new JsonContent
                            {
                                id = qElem.id,
                                distrib_id = qElem.distrib_id,
                                content_title = qElem.content_title,
                                content_body = qElem.content_body
                            };

            return Json(jsonQuery.ToList());
        }

    }
}
